<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="renderer" content="webkit" />
  <meta name="robots" content="index, follow" />
  <title>KELLY RIGHT ™</title>
  <meta name="description" content="" />
  <meta name="keywords" content="" />
  <meta name="author" content="order by website" />
  <link rel="shortcut icon" href="skin/fonts/favicon.ico" />
  <link rel="bookmark" href="skin/fonts/favicon.ico" />
  <link rel="stylesheet" type="text/css" href="skin/css/font-awesome.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/bootstrap.min.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/owl.carousel.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/owl.theme.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/settings.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/style-red.css" media="screen" />
  <link rel="stylesheet" type="text/css" href="skin/css/tk.css" media="screen" />
  <script type="text/javascript" src="skin/js/jquery.min.js"></script>
  <script type="text/javascript" src="skin/js/jquery.autocomplete.js"></script>
  <!-- <script type='text/javascript' src='skin/js/fastclick.js'></script> -->
  <script type="text/javascript" src="skin/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="skin/js/template-web.js"></script>
  <script type="text/javascript" src="skin/js/owl.carousel.min.js"></script>
  <!-- Similar Listings -->
  <script type="text/html" id="similar">
    {{if slist.length}}
      <h3 class="text-center section-title titles">
        <a href="javascript:;" class="chi">Listings You Might Be Interested In</a>
      </h3>
    {{/if}}

    <div class="portfolio-box owl-wrapper" id="simLists">

      <div class="owl-carousel" id="owl-example" data-num="4">
        {{each slist v i}}

        <div class="item project-post" data-id="{{v.mlsId}}">
          <div class="newBoxs">
            <div class="project-gallery">
              <img src="{{v.photos[0]}}" />

              <div class="hover-box">
                ${{v.listPrice}}
              </div>
            </div>

            <div class="introducts">
              <h3 class="iport-h3-title">{{v.address.full}}</h3>

              <ul class="tbox clearfix">
                <li>{{v.address.city}}</li>
                <li>{{v.address.state}}</li>
              </ul>

              <ul class="tbox box2 clearfix">
                {{ if (v.property.bedrooms) }}
                <li>{{v.property.bedrooms}} bd</li>
                {{ /if }}

                {{ if (v.property.bathsFull) }}
                <li>{{v.property.bathsFull}} ba</li>
                {{ /if }}

                {{ if (v.property.area)}}
                <li>{{v.property.area}} sf</li>
                {{ /if }}
              </ul>

              <div class="footer clearfix">
                <div class="lagent">
                  <div class="nms">{{v.agent.firstName}} {{v.agent.lastName}}</div>
                  <div class="dl">{{v.office.servingName}}</div>
                </div>
                <!-- <div class="raixin">
                  {{if (v.isCollect != 1)}}
                  <img src="./skin/images/aixin.png" alt="">
                  {{else if(v.isCollect == 1)}}
                  <img src="./skin/images/aixin_full.png" alt="">
                  {{/if}}
                </div>
                <div class="mask" data-item="{{v}}"></div> -->
              </div>
            </div>
          </div>

        </div>

        {{/each}}
      </div>
    </div>
  </script>

  <!-- Latest Listings -->
  <script type="text/html" id="latest">
    {{if llist.length}}
      <h3 class="text-center section-title titles">
        <a href="javascript:;" class="chi">Latest Listings</a>
      </h3>
    {{/if}}

    <div class="news-box owl-wrapper" id="latests">

      <div class="owl-carousel" id="owl-latestEx" data-num="4">
        {{each llist v i}}
        <div class="item project-post" data-id="{{v.mlsId}}">
          <div class="project-gallery">
            <img src="{{v.photos[0]}}" />

            <div class="hover-box">
              ${{v.listPrice}}
            </div>
          </div>

          <div class="introducts">
            <h3 class="iport-h3-title">{{v.address.full}}</h3>

            <ul class="tbox clearfix">
              <li>{{v.address.city}}</li>
              <li>{{v.address.state}}</li>
            </ul>

            <ul class="tbox box2 clearfix">
              {{ if (v.property.bedrooms) }}
              <li>{{v.property.bedrooms}} bd</li>
              {{ /if }}

              {{ if (v.property.bathsFull) }}
              <li>{{v.property.bathsFull}} ba</li>
              {{ /if }}

              {{ if (v.property.area)}}
              <li>{{v.property.area}} sf</li>
              {{ /if }}
            </ul>

            <div class="footer clearfix">
              <div class="lagent">
                <div class="nms">{{v.agent.firstName}} {{v.agent.lastName}}</div>
                <div class="dl">{{v.office.servingName}}</div>
              </div>
              <!-- <div class="raixin">
                {{if (v.isCollect != 1)}}
                <img src="./skin/images/aixin.png" alt="">
                {{else if(v.isCollect == 1)}}
                <img src="./skin/images/aixin_full.png" alt="">
                {{/if}}
              </div>
              <div class="mask" data-item="{{v}}"></div> -->
            </div>
          </div>

        </div>
        {{/each}}
      </div>
    </div>
  </script>

</head>

<body>
  <div id="container" class="home">
    <!-- sign in -->
    <div class="signin none">
      <div class="content">
        <!-- 关闭 -->
        <div class="closebtn"></div>

        <!-- logo -->
        <div class="dllogos">
          <div class="photo">
            <img src="./skin/images/log-logo.png" class="thepicture" alt="">
          </div>
        </div>

        <!-- 提示登录 -->
        <!-- <div class="tsinfo">Please login to your account before seeing the information. </div> -->

        <!-- 用户 -->
        <div class="userinfo login-normal" id="userInfo">
          <form action="">
            <!-- 导航 -->
            <div class="row navbares" id="signNav">

              <div class="col-xs-4 col-xs-offset-4 col-sm-2 col-sm-offset-7 up">
                <span>Sign Up</span>
              </div>

              <div class="col-xs-4 col-sm-2 log active">
                <span>Log In</span>
              </div>

            </div>

            <!-- sign up -->
            <div class="row usersignup">
              <!-- <div class="row free">
                Create a FREE account to save searches and track your favourite homes. Already have an account? Click
                the Log In tab.
              </div> -->

              <!-- 提示 -->
              <div class="row upalert" id="upginTips">You have signed up successfully, please log in to account.</div>

              <div class="row name">
                <div class="title">Name</div>
                <input type="text" placeholder="" name="" id="input_name1">
                <div class="ts">cannot be blank</div>
              </div>

              <div class="row email">
                <div class="title">Email</div>
                <input type="email" placeholder="" name="" id="input_email1">
                <div class="ts">please enter the correct email</div>
                <div class="exist">account already exists</div>
              </div>

              <div class="row password">
                <div class="title">Phone Number <span class="usedfor">(Used for Password)</span></div>
                <input type="text" placeholder="" name="" id="input_password1">
                <div class="ts">cannot be blank</div>
              </div>

              <!-- <div class="row confirm">
                <div class="title">Confirm Password</div>
                <input type="password" placeholder="" name="" id="input_confirm1">
                <div class="ts">does not match password</div>
              </div> -->

              <!-- 确定 -->
              <div class="row upsubmit">
                <p class="tj active">Sign Up</p>
              </div>

              <div class="row confirm2">
                <!-- <input type="checkbox" name="" value="0" id=""> -->
                <div class="pictur active"></div>
                <div class="fktxt">
                  Get emailed when we find more properties that suit your tastes! We'll notify you daily of new
                  listings & price changes.
                </div>
              </div>

              <div class="row bottomTiS">
                By clicking continue or sign up, you agree to our linked <span class="hs">Terms of Use</span> and <span
                  class="hs">Privacy Policy</span>
              </div>
            </div>

            <!-- log in -->
            <div class="row usersignin">
              <!-- <div class="row tit">
                <p>
                  Don't have an account? Click on the Sign Up tab.
                </p>
              </div> -->

              <!-- 提示 -->
              <div class="row alert" id="loginTips">Invalid email or password.</div>

              <div class="row email">
                <div class="title">Email</div>
                <input type="email" name="" placeholder="" id="input_email">
                <div class="ts">Please enter the correct email</div>
              </div>

              <div class="row password">
                <div class="title">Phone Number <span class="usedfor">(Used for Password)</span></div>
                <input type="text" name="" placeholder="" id="input_password">
                <div class="ts">cannot be blank</div>
              </div>

              <div class="row loginsubmits">
                <p class="tj active">Log In</p>
              </div>

              <!-- 是否保持状态 忘记密码 -->
              <div class="row combine">
                <!-- 保持状态 -->
                <div class="col-xs-12 col-sm-6 rad">
                  <!-- <input type="checkbox" value="0" name="agree" id="check"> -->
                  <div class="pictur active"></div>
                  Stay logged in
                </div>

                <div class="col-xs-12 col-sm-6 access">
                  <p>
                    <a href="javascript: void(0);" id="forgetword">Can't access your account?</a>
                  </p>
                </div>

              </div>


            </div>

          </form>

        </div>

        <!-- 忘记密码 -->
        <div class="row findpassword login-find" style="display: none;">
          <div class="row tit">
            <p>
              Enter the email address you registered with and your password will be sent to you.
            </p>
          </div>

          <!-- 提示 -->
          <div class="row alert" id="findpaTips">Invalid email.</div>

          <div class="row email" id="emaFi">
            <div class="title">Email</div>
            <input type="email" name="" placeholder="" id="sendEmail">
            <div class="ts">Please enter the correct email.</div>
          </div>

          <div class="row send" id="sendPass">
            <p class="tj active">Send Password</p>
          </div>

          <div class="row back">
            <p>
              <a href="javascript: void(0);">Back to log in page</a>
            </p>
          </div>

        </div>

      </div>
    </div>

    <div class="zongbox">

      <!-- 导航栏 -->
      <header class="clearfix" id="header-sec">
        <nav class="navbar navbar-default navbar-fixed-top pbox" role="navigation">

          <div class="container-fluid">

            <!-- 左 logo -->
            <div class="navbar-header">
              <!-- 移动端按钮 折叠 -->
              <a class="navbar-toggle collapsed mmenu-btn" href="#mmenu">
                <!-- <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span> 
                    <span class="icon-bar"></span> 
                    <span class="icon-bar"></span>  -->
                <img src="./skin/images/mobile-tab.png" alt="">
              </a>

              <!-- pc -->
              <a class="navbar-brand hidden-xs hidden-sm hiddenMobEle" href="javascript:;">
                <img src="./skin/images/logo.png" alt="" class="logo" />
              </a>

              <!-- 移动 -->
              <a class="navbar-brand hidden-md hidden-lg hiddenPccEle" href="javascript:;">
                <img src="./skin/images/log-logo.png" alt="" class="logo" />
              </a>

            </div>

            <!-- tab -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

              <ul class="nav navbar-nav navbar-left" id="navigation1">
                <li class="Lev1">
                  <a href="./index.html" class='menu1 active'>Homes for Sale </a>
                </li>

                <li class="Lev1">
                  <a href="./aboutCharlotte.html" class='menu1'>About Charlotte</a>
                </li>

                <li class="Lev1">
                  <a href="./contactUs.html" class='menu1'>Contact Us</a>
                </li>

                <!-- <li class="Lev1">
                      <a href="./openHouses.html" class="menu1">Open Houses</a>
                    </li> -->

                <!-- <li class="Lev1">
                      <a href="javascript:void(0);" class="menu1">New Developments</a>
                    </li>
      
                    <li class="Lev1">
                      <a href="javascript:void(0);" class="menu1">Buildings
                      </a>
      
                    </li>
      
                    <li class="Lev1">
                      <a href="javascript:void(0);" class="menu1">Find an Agent
                      </a>
      
                    </li>
      
                    <li class="Lev1">
                      <a href="javascript:void(0);" class="menu1">Blog
                      </a>
                    </li> -->
              </ul>

              <ul class="nav navbar-nav navbar-right" id="navigation2">

                <li class="Lev1">
                  <a href="./sign-up.html" class="menu1 giwid">SIGN UP</a>
                </li>

                <li class="Lev1">
                  <a href="javascript:void(0);" class="menu1 giwid activeLogin">LOG IN</a>
                </li>

                <li class="afterLogin" style="display: none">
                  <a class="ele-a" href="#">
                    <!-- 注册时输入的用户名 -->
                    <span class="atext">username</span>
                    <div class="arr-down">
                      <img src="./skin/images/jiantouxia.png" alt="">
                    </div>
                  </a>

                  <!-- 用户相关 -->
                  <ul class="aboutUser">
                    <li class="item">
                      <a href="./account-details.html" class="in">
                        <span class="">Account Details</span>
                      </a>
                    </li>

                    <li class="item" id="userFavourite">
                      <a href="./collection.html" class="in">
                        <span class="">Favorites</span>
                        <span class="favNum">0</span>
                      </a>
                    </li>

                    <li class="item">
                      <p class="signOut">Sign Out</p>
                    </li>
                  </ul>

                </li>

              </ul>

            </div>

          </div>

        </nav>
      </header>

      <!-- banner -->
      <div id="home-section" class="slider1">
        <!-- 内容 -->
        <div class="contents">
          <div class="top">
            <h1 class="title">Find homes for sale in Spokane.</h1>
          </div>

          <!-- 搜索 -->
          <div class="searchbox">
            <div class="tsearch clearfix">
              <div class="le">
                <input type="text" class="sr" name="country" id="autocomplete"
                  placeholder="Neighborhood, Address, School">
                <!-- 按钮 -->
                <div class="rig">
                  <!-- <i class="fa fa-search"></i> -->
                  <img src="./skin/images/icon_search.png" style="width: 22px; height: 22px;" alt="">
                </div>
              </div>

              <!-- <div class="bymaps" id="byMap">
                Search by Map
              </div> -->

            </div>

            <!-- 上次搜索 -->
            <div class="recent">
              <h3 class="tit">Recently Searched</h3>
              <div class="searched">
                <p class="pha"> <span id="recented">Ajax</span> <span class="lis">Listings</span></p>
              </div>
            </div>

            <!-- 智能提示 -->
            <div class="znts">
              <!-- <h1 class="title">CITIES</h1> -->
              <div id="suggestions-container" class="tsboxs" style=""></div>
            </div>

          </div>

          <!-- 条件 -->
          <div class="type">
            <div class="row box">
              <div class="col-xs-12 col-sm-6 col-sm-offset-3 item item1">
                <div class="a" id="byMap">
                  <div class="ibox">
                    Search by Map
                    <!-- Search by <span class="sp">Map</span> -->
                  </div>
                </div>
              </div>

              <!-- <div class="col-xs-6 item item2">
                <div class="a" id="byNeighbourhood">
                  <div class="ibox">
                    Search by <span class="sp">Neighborhood</span>
                  </div>
                </div>
              </div> -->
            </div>
          </div>

        </div>

      </div>

    </div>

    <!-- Similar Listings 类似列表 -->
    <div class="portfolio-section portfolio1 similar" id="index-portfolio">
      <div class="container" id="simlarTotalBox"></div>
    </div>

    <!-- Latest Listings 最新列表 -->
    <div class="portfolio-section portfolio2 latest" id="index-news">
      <div class="container" id="lastTotalBox"></div>
    </div>

    <!-- 加载中 -->
    <div class="load">
      <div class="ing">
        <img src="./skin/images/jiazaizhong.gif" class="photo" alt="">
      </div>
    </div>

    <!-- 提示: 登录成功 -->
    <div class="success-logIn">
      <img class="pic" src="./skin/images/dui.png" alt="">
      <span class="txt">Logged in successfully.</span>
      <div class="close">
        <img src="./skin/images/guanbi.png" alt="">
      </div>
    </div>

    <!-- 提示: 退出成功 -->
    <div class="success-signOut">
      <img class="pic" src="./skin/images/dui.png" alt="">
      <span class="txt">Signed out successfully.</span>
      <div class="close">
        <img src="./skin/images/guanbi.png" alt="">
      </div>
    </div>

    <!-- 提示: 到邮箱找回密码 -->
    <div class="findmailbox">
      <img class="pic" src="./skin/images/dui.png" alt="">
      <span class="txt">You will receive an email with instructions about how to reset your password in a few
        minutes.</span>
      <div class="close">
        <img src="./skin/images/guanbi.png" alt="">
      </div>
    </div>

    <!-- 底部 -->
    <div class="commonfoot">
      <div class="container  hidden-xs hidden-sm">

        <div class="row">

          <div class="col-md-4 col-lg-4  foot-contact rightbox">
            <div class="f-contact ltxt">
              <p> <a href="javascript:void(0);">© 2019 Real Estate Website by DotCom Agents</a></p>
              <p> <a href="javascript:void(0);">All rights reserved. Privacy and Terms</a></p>
            </div>
          </div>

          <div class="col-md-4 col-lg-4 foot-contact">
            <div class="f-contact">
              <ul class="box clearfix">
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom1.png" alt="" class="pic">
                  </a>
                </li>
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom2.png" alt="" class="pic">
                  </a>
                </li>
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom3.png" alt="" class="pic">
                  </a>
                </li>
              </ul>
            </div>
          </div>

          <div class="col-md-4 col-lg-4 foot-contact">
            <div class="f-contact rtxt">
              <p> <a href="./aboutCharlotte.html">ABOUT US</a></p>
              <p> <a href="./contactUs.html">CONTACT US</a></p>
            </div>
          </div>

        </div>

      </div>

      <div class="container hidden-md  hidden-lg">

        <div class="row">

          <div class="col-xs-12 col-sm-12 foot-contact">
            <div class="f-contact one">
              <ul class="about clearfix">
                <li><a href="./aboutCharlotte.html">ABOUT US</a></li>
                <li><a href="./contactUs.html">CONTACT US</a></li>
              </ul>
            </div>
          </div>

          <div class="col-xs-12 col-sm-12 foot-contact">
            <div class="f-contact two">
              <ul class="box clearfix">
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom1.png" alt="" class="pic">
                  </a>
                </li>
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom2.png" alt="" class="pic">
                  </a>
                </li>
                <li>
                  <a href="javascript:void(0);">
                    <img src="./skin/images/bottom3.png" alt="" class="pic">
                  </a>
                </li>
              </ul>
            </div>
          </div>

          <div class="col-xs-12 col-sm-12  foot-contact">
            <div class="f-contact three">
              <p> <a href="javascript:void(0);">© 2019 Real Estate Website by DotCom Agents</a></p>
              <p> <a href="javascript:void(0);">All rights reserved. Privacy and Terms</a></p>
            </div>
          </div>
        </div>

      </div>
    </div>

  </div>

  <script type="text/javascript" src="skin/js/jquery.migrate.js"></script>
  <!-- <script type="text/javascript" src="skin/js/jquery.bxslider.min.js"></script> -->
  <script type="text/javascript" src="skin/js/jquery.imagesloaded.min.js"></script>
  <script type="text/javascript" src="skin/js/retina-1.1.0.min.js"></script>
  <script type="text/javascript" src="skin/js/jquery.themepunch.tools.min.js"></script>
  <script type="text/javascript" src="skin/js/jquery.themepunch.revolution.min.js"></script>
  <script type="text/javascript" src="skin/js/script.js"></script>

  <!-- 移动端导航 -->
  <nav id="mmenu" class="noDis">
    <div class="mmDiv">

      <!-- 关闭 -->
      <div class="closefixed closemenu">
        <img src="./skin/images/close_pic.png" alt="" style="width: 20px; height: 20px;">
      </div>

      <!-- sign log -->
      <div class="MMhead">
        <ul class="users clearfix">
          <!-- 登录前 -->
          <li class="before before1">
            <a href="./sign-up.html" class="noblock logins">Sign Up</a>
          </li>

          <li class="before">
            <a href="javascript:;" class="noblock activeLogin">Log In</a>
          </li>

          <!-- 登录后 -->
          <!-- Account Details -->
          <li class="afters afters1">
            <a href="./account-details.html" class="item account">
              <img src="./skin/images/log-ren.png" class="pic" alt="">
            </a>
          </li>

          <!-- Favourites -->
          <li class="afters">
            <a href="./collection.html" class="item account">
              <img src="./skin/images/log-aixin.png" class="pic" alt="">
              <span class="num" id="faNum">0</span>
            </a>
          </li>

        </ul>

      </div>


      <!-- nav -->
      <ul class="mobnavbar">
        <li class="box">
          <a href="./index.html" style="color: #F39800;">Homes for Sale</a>
        </li>

        <li class="box">
          <a href="./aboutCharlotte.html">About Charlotte</a>
        </li>

        <li class="box">
          <a href="./contactUs.html">Contact Us</a>
        </li>


        <!-- <li class="box">
            <a href="./openHouses.html" class="m-menu1">Open Houses</a>
          </li> -->

        <!-- <li class="box">
            <a href="javascript:;" class="m-menu1">New Developments</a>
          </li>
  
          <li class="box">
            <a href="" class="m-menu1">Buildings</a>
          </li>
  
          <li class="box">
            <a href="" class="m-menu1">Find an Agent</a>
          </li>
          
          <li class="box">
            <a href="" class="m-menu1">Find an Agent</a>
          </li>
  
          <li class="box">
            <a href="javascript:;" class="m-menu1">Blog</a>
          </li> -->
      </ul>

      <!-- sign out 登录后出现 -->
      <div class="footout">
        <a class="" href="javascript:;">Sign Out</a>
      </div>

    </div>
  </nav>

  <link type="text/css" rel="stylesheet" href="skin/css/jquery.mmenu.all.css" />
  <script type="text/javascript" src="skin/js/jquery.mmenu.all.min.js"></script>
  <script type="text/javascript" src="skin/js/base64.min.js"></script>
  <script type="text/javascript" src="skin/js/base.js"></script>
  <script type="text/javascript" src="skin/js/axios.min.js"></script>
  <script type="text/javascript" src="skin/js/index.js"></script>
  <script type="text/javascript">
    $(function ($) {
      var baseUrl = localStorage.getItem('baseUrl');
      var askKey = 'q'; // 搜索
      var askVal = ''; // 搜索词
      var fields = {};
      var cities = [];
      var counties = [];
      var neighborhoods = [];

      var LatestList = [];

      // 获取智能搜索
      ;
      (function getHelpList() {
        // (2) 请求--获取数据
        axios.post(baseUrl + '/mclient/srts/basicAttri', {}, {
            headers: {
              'token': localStorage.getItem('token')
            }
          })

          .then(function (res) {

            if (res.data.code == 0 && res.data.msg == "success") {
              console.log('-----获取提示列表成功-----', res);

              // (2.1) 存储
              fields = res.data.results.fields;
              localStorage.setItem('fields', res.data.results.fields);

              cities = res.data.results.fields.cities;
              counties = res.data.results.fields.counties;
              neighborhoods = res.data.results.fields.neighborhoods;

              var handCity = [];

              // (2.1.1) 处理 -- cities
              if (cities && cities.length) {
                cities.map((item, index, arr) => {
                  handCity.push({
                    value: (item + ' (city)'),
                    data: item
                  });
                })
              }

              // (2.1.2) 处理 -- counties
              if (counties && counties.length) {
                counties.map((item, index, arr) => {
                  handCity.push({
                    value: (item + ' (county)'),
                    data: item
                  });
                })
              }

              // (2.1.3) 处理 -- neighborhoods
              if (neighborhoods && neighborhoods.length) {
                neighborhoods.map((item, index, arr) => {
                  handCity.push({
                    value: (item + ' (neighbourhood)'),
                    data: item
                  });
                })
              }

              // 渲染
              var countries = handCity;

              $('#autocomplete').autocomplete({
                lookup: countries,
                onSelect: function (res) {
                  var selectWords = res.value;
                  // askVal = res.value;

                  if (!String.prototype.contains) {
                    String.prototype.contains = function (arg) {
                      return !!~this.indexOf(arg);
                    };
                  }

                  // 去掉备注
                  if (selectWords.contains(' (city)')) {
                    askKey = 'cities';
                    selectWords = selectWords.replace(' (city)', '');

                  } else if (selectWords.contains(' (county)')) {
                    askKey = 'counties';
                    selectWords = selectWords.replace(' (county)', '');

                  } else if (selectWords.contains(' (neighbourhood)')) {
                    askKey = 'neighborhoods';
                    selectWords = selectWords.replace(' (neighbourhood)', '');
                  }


                  askVal = selectWords;

                  // if(cities && cities.length) {
                  //   cities.map((item, index, arr) => {
                  //     if(item == selectWords) {
                  //       askKey = 'cities';
                  //     }
                  //   })
                  // }

                  // if(counties && counties.length) {
                  //   counties.map((item, index, arr) => {
                  //     if(item == selectWords) {
                  //       askKey = 'counties';
                  //     }
                  //   })
                  // }

                  // if(neighborhoods && neighborhoods.length) {
                  //   neighborhoods.map((item, index, arr) => {
                  //     if(item == selectWords) {
                  //       askKey = 'neighborhoods';
                  //     }
                  //   })
                  // }

                  // 存储历史搜索词
                  localStorage.setItem('key', askKey);
                  localStorage.setItem('value', askVal);

                  sessionStorage.removeItem('fromList');

                  window.location.href = `./saleList.html?key=${askKey}&value=${askVal}`;
                }
              });



            } else {
              console.log('-----报错-----', res.data.msg);
            }

          })

          .catch(function (error) {
            console.log('-----请求提示失败-----', error);
          });

      })();

      // money
      function formatNum(str) {
        var str = typeof str == 'string' ? str : str + '';
        var newStr = "";
        var count = 0;
        // 当数字是整数
        if (str.indexOf(".") == -1) {
          for (var i = str.length - 1; i >= 0; i--) {
            if (count % 3 == 0 && count != 0) {
              newStr = str.charAt(i) + "," + newStr;
            } else {
              newStr = str.charAt(i) + newStr;
            }
            count++;
          }
          str = newStr; //自动补小数点后两位  + ".00"
          return str;
        }
        // 当数字带有小数
        else {
          for (var i = str.indexOf(".") - 1; i >= 0; i--) {
            if (count % 3 == 0 && count != 0) {
              newStr = str.charAt(i) + "," + newStr;
            } else {
              newStr = str.charAt(i) + newStr; //逐个字符相接起来
            }
            count++;
          }
          str = newStr + (str + "00").substr((str + "00").indexOf("."), 3);
          return str;
        }
      }

      // 1 点击搜索
      $('.tsearch').on('click', '.rig', function () {
        // 获取关键字
        var q = $('.tsearch .le .sr').val();
        var ischange = true;

        if (!q) {
          return;
        }

        if (cities && cities.length) {
          cities.map((item, index, arr) => {
            if (item == q) {
              askKey = 'cities';
              ischange = false;
            }
          })
        }

        if (counties && counties.length) {
          counties.map((item, index, arr) => {
            if (item == q) {
              askKey = 'counties';
              ischange = false;
            }
          })
        }

        if (neighborhoods && neighborhoods.length) {
          neighborhoods.map((item, index, arr) => {
            if (item == q) {
              askKey = 'neighborhoods';
              ischange = false;
            }
          })
        }

        // 随机显示一项
        if (ischange) {
          askKey = 'q';

          // if(neighborhoods && neighborhoods.length) {
          //   var max = 0;
          //   var min = neighborhoods.length - 1;
          //   var sjnum = Math.floor( Math.random() * (max - min + 1) + min );
          //   console.log('-----随机数-----', neighborhoods[sjnum]);
          //   q = neighborhoods[sjnum];
          // }

        }

        // 存储搜索词
        localStorage.setItem('key', askKey);
        localStorage.setItem('value', q);

        sessionStorage.removeItem('fromList');

        // 跳转列表页
        window.location.href = `./saleList.html?key=${askKey}&value=${q}`;
      })

      $(".tsearch .sr").keyup(function (e) {
        if (e.which === 13) {
          $(".tsearch .rig").click();
        }
      });

      // 2.1 搜索 -- focus -- 显示历史记录
      $('.tsearch .sr').focus(function () {
        // 上次有搜索
        var q1 = localStorage.getItem('value');
        if (q1) {
          // 显示
          $('.recent .searched #recented').text(q1);
          $('.searchbox .recent').show();
        } else {
          $('.recent .searched #recented').text();
          $('.searchbox .recent').hide();
        }
      })

      // 2.2 搜索 -- blur
      $('.home').on('click', '.zongbox', function (e) {
        var q1 = localStorage.getItem('value');
        if (q1) {
          var currElement = e.toElement.className;
          if (currElement == 'sr' || currElement == 'tit' || currElement == 'span#recented' || currElement == 'p.pha' || currElement == 'span.lis') {
            $('.searchbox .recent').show();
          } else {
            $('.searchbox .recent').hide();
          }
        }
      })


      // 2.3 搜索 -- input
      $('.tsearch').on('input', '.sr', function () {

        // (1) 获取input的值
        var inputValue = $(this).val();

        // (2) 隐藏 历史
        if (inputValue) {
          $('.searchbox .recent').hide();
        } else {
          var q1 = localStorage.getItem('value');
          if (q1) {
            // 显示
            $('.recent .searched #recented').text(q1);
            $('.searchbox .recent').show();
          } else {
            $('.recent .searched #recented').text();
            $('.searchbox .recent').hide();
          }
        }

      })

      // 2.4 点击 -- 上次搜索
      $('.recent').on('click', '.searched', function (e) {

        var oldkey = localStorage.getItem('key');
        var oldval = localStorage.getItem('value');
        
        sessionStorage.removeItem('fromList');
        window.location.href = `./saleList.html?key=${oldkey}&&value=${oldval}`;
        return false;
      })

      // 2.5 搜索 -- change
      $('.tsearch .sr').keyup(function () {
        $('.searchbox .recent').hide();
      })

      // 3.1 点击 -- map
      $('#home-section').on('click', '#byMap', function () {
        window.location.href = './property-byMap.html';
      })
      // 3.2 点击 -- neighbourhood
      $('#home-section').on('click', '#byNeighbourhood', function () {
        window.location.href = './property-byNeighbourhood.html';
      });

      // 4 获取 Similar Listings 类似列表
      function getSimilarListings() {
        // 前提 -- 登录
        var token = localStorage.getItem('token');
        if (!token) {
          var similarList = [];
          var html1 = template('similar', {
            slist: similarList
          });
          $('.home #index-portfolio #simlarTotalBox').html(html1);

        } else {

          // 请求
          axios.post(baseUrl + '/mclient/srts/list4Similar', {}, {
              headers: {
                'token': localStorage.getItem('token')
              }
            })

            .then(function (res) {

              if (res.data.code == 0 && res.data.msg == "success") {
                console.log('-----获取 Similar Listings 成功-----', res);

                var getTheList = res.data.results;
                var similarList = [];
                if (getTheList && getTheList.length) {
                  getTheList.map((item, index, arr) => {
                    if (index >= 0 && index <= 3) {
                      similarList.push(item);
                    }
                  })
                }

                // 处理
                if (similarList && similarList.length) {
                  similarList.map((item, index, arr) => {
                    if (item.listPrice) {
                      item.listPrice = formatNum(item.listPrice);
                    }
                  })
                }

                var html2 = template('similar', {
                  slist: similarList
                });
                $('.home #index-portfolio #simlarTotalBox').html(html2);

                $("#owl-example").owlCarousel({
                  items: 4,
                  lazyLoad: false,
                  autoPlay: false,
                  navigation: false,
                  navigationText: false,
                  pagination: true
                });



              } else {
                console.log('-----报错-----', res.data.msg);
              }

            })

            .catch(function (error) {
              console.log('-----获取 Similar Listings 失败-----', error);
            });

        }

      };
      getSimilarListings();


      // 5 获取 Latest Listings 最新列表
      function getLatestListings() {
        // 请求
        var params2 = {
          "limit": "4",
          "offset": "0"
        }
        console.log('-----获取 Latest Listings 传参-----', params2);

        axios.post(baseUrl + '/mclient/srts/list4Latest', params2, {
            headers: {
              'token': localStorage.getItem('token')
            }
          })

          .then(function (res) {

            if (res.data.code == 0 && res.data.msg == "success") {
              console.log('-----获取 Latest Listings 成功-----', res);

              var getList = res.data.results;
              LatestList = [];
              if (getList && getList.length) {
                getList.map((item, index, arr) => {
                  if (index >= 0 && index <= 3) {
                    LatestList.push(item);
                  }
                })
              }

              // 处理
              if (LatestList && LatestList.length) {
                LatestList.map((item, index, arr) => {
                  if (item.listPrice) {
                    item.listPrice = formatNum(item.listPrice);
                  }
                })
              }

              var html3 = template('latest', {
                llist: LatestList
              });
              $('.home #index-news #lastTotalBox').html(html3);

              $("#owl-latestEx").owlCarousel({
                items: 4,
                lazyLoad: false,
                autoPlay: false,
                navigation: false,
                navigationText: false,
                pagination: true,
              });



            } else {
              console.log('-----报错-----', res.data.msg);
            }

          })

          .catch(function (error) {
            console.log('-----获取 Latest Listings 失败-----', error);
          });

      };
      getLatestListings();


      // 6.1 点击 Similar Listings 的收藏
      $('.home #simlarTotalBox').on('click', '.mask', function (e) {
        e.stopPropagation();

        // 前提--登录
        if (localStorage.getItem('token')) {

          var item1 = $(this).data().item;

          // 请求
          var params5 = {
            'mlsId': item1.mlsId + '',
            'propertiesData': item1,
            'actionDo': item1.isCollect == 1 ? -1 : 1 // -1 取消
          };

          axios.post(baseUrl + '/mclient/member/collectProperties', params5, {
              headers: {
                'token': localStorage.getItem('token')
              }
            })

            .then(function (res) {

              if (res.data.code == 0 && res.data.msg == "success") {
                console.log('-----收藏成功-----', res);

                // 刷新列表
                getSimilarListings();

                // 2 获取收藏数
                // getLikeList();

              } else {
                console.log('----- 收藏不成功 -----', res);
              }

            })

            .catch(function (res) {
              console.log('-----请求收藏接口失败-----', res);
            });

        } else {

          // 未登录--提示
          $('.signin').show();
          $('.signin .content').slideDown();
        }

      })

      // 6.2 点击 Latest Listings 的收藏
      $('.home #lastTotalBox').on('click', '.mask', function (e) {
        e.stopPropagation();

        // 前提--登录
        if (localStorage.getItem('token')) {

          var item1 = $(this).data().item;

          // 请求
          var params6 = {
            'mlsId': item1.mlsId + '',
            'propertiesData': item1,
            'actionDo': item1.isCollect == 1 ? -1 : 1 // -1 取消
          };

          axios.post(baseUrl + '/mclient/member/collectProperties', params6, {
              headers: {
                'token': localStorage.getItem('token')
              }
            })

            .then(function (res) {

              if (res.data.code == 0 && res.data.msg == "success") {
                console.log('-----收藏成功-----', res);
                
                // 刷新列表
                getLatestListings();

                // 2 获取收藏数
                // getLikeList();

              } else {
                console.log('----- 收藏不成功 -----', res);
              }

            })

            .catch(function (res) {
              console.log('-----请求收藏接口失败-----', res);
            });

        } else {

          // 未登录--提示
          $('.signin').show();
          $('.signin .content').slideDown();
        }

      })
     
      // 7 获取收藏数
      var likeListResult = [];

      function getLikeList() {

        axios.post(baseUrl + '/mclient/member/collectList', {}, {
            headers: {
              'token': localStorage.getItem('token')
            }
          })

          .then(function (res) {

            if (res.data.code == 0 && res.data.msg == "success") {
              console.log('-----获取收藏列表成功-----', res);
              likeListResult = res.data.results;

              if (likeListResult) {
                $('.aboutUser #userFavourite .favNum').text(likeListResult.length);
                $('.users .afters #faNum').text(likeListResult.length); //移动端
              }

            } else {
              console.log('-----获取收藏列表不成功-----', res);
            }

          })

          .catch(function (res) {
            console.log('-----请求收藏列表接口失败-----', res);
          });

      };

      // 8.1 点击每项 -- Similar Listings
      $('.home #simlarTotalBox').on('click', '.item', function (e) {

        var id = $(this).data().id;
        // 跳转详情页
        window.location.href = `./saleDetail.html?id=${id}`;

      });

      // 8.2 点击每项 -- Latest Listings
      $('.home #lastTotalBox').on('click', '.item', function (e) {

        var id = $(this).data().id;
        // 跳转详情页
        window.location.href = `./saleDetail.html?id=${id}`;

      });


    });
  </script>
</body>

</html>